def sum_1(s1, s2):
	cnt = {}
	n = len(s1)
	sum = 0
	for i in range(n):
		if s2[i] not in cnt: cnt[s2[i]] = 0
		if s1[i] not in cnt: cnt[s1[i]] = 0
		cnt[s2[i]] += i + 1	
		sum += cnt[s1[i]] * (n-i)
#	print 'sum1', sum
	return sum

def sum_2(s1, s2):
	cnt = {}
	n = len(s1)
	sum = 0
	for i in range(n):
		if s2[i] not in cnt: cnt[s2[i]] = 0
		if s1[i] not in cnt: cnt[s1[i]] = 0
		sum += cnt[s1[i]] * (n-i)
		cnt[s2[i]] += i + 1	
#	print 'sum2', sum
	return sum

def cal_all(n):
	print 'all', reduce(lambda x,y: x+y*y, range(1,n+1))
	return reduce(lambda x,y: x+y*y, range(1,n+1))

n = input()
s1 = raw_input()
s2 = raw_input()
print 1.0*(sum_1(s1,s2) + sum_1(s2,s1)) / cal_all(n)  

